<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="username">
    <input type="text" id="password">

    <script>
        var username = document.getElementById("username");
        username.oninput = function(e){
            console.log(e.target.value);//读取数据
            
        }
//select事件当在<input>、<textarea>里面选中文本时触发
        username.onselect = function(){
            console.log("选中了");
            
        }


//change事件当<input>、<select>、<textarea>的值发生变化时触发。它与input事件的最大不同，就是不会连续触发，
//只有当全部修改完成时才会

    var password = document.getElementById("password");
    password.onchange = function(e){//失去焦点和回车的时候触发
        console.log(e.target.value);
        
    }
    </script>
</body>
</html>